/*
 * app.c
 *
 *  Created on: May 23, 2024
 *      Author: chain
 */


#include "main.h"
#include "cmsis_os.h"
#include "time.h"
#include "log.h"
#include "task.h"
#include "string.h"
#include "stm32_uart.h"
#include "stdio.h"


uint32_t utc_count = 0;


void utc_callback(void *argument)
{
    /* USER CODE BEGIN utc_callback */
    utc_count ++;
    /* USER CODE END utc_callback */
}

void StartDefaultTask(void *argument)
{
    uint8_t hmi_rx_buff[128];
    uint16_t hmi_rx_len;
    int hour,min;

    /* USER CODE BEGIN 5 */
    LOGI("StartDefaultTask\r\n");


    /* Infinite loop */
    for(;;)
    {
//    osDelay(1);

        memset(hmi_rx_buff, 0, sizeof(hmi_rx_buff));
        hmi_rx_len = stm32_uart_recv(UART1_PORT, hmi_rx_buff, sizeof(hmi_rx_buff), portMAX_DELAY);
        if (hmi_rx_len>0)
        {
            sscanf(hmi_rx_buff, "#SET_TIME:%d,%d", &hour, &min);
            stm32_uart_send(UART1_PORT, "12345678", 8);
        }


  }
  /* USER CODE END 5 */
}


//log输出时间
uint32_t SEGGER_SYSVIEW_X_GetTimestamp(void)
{
    return __get_IPSR() ? xTaskGetTickCountFromISR() : xTaskGetTickCount();
}


